﻿package com.tudou.home.view.ad
{
    import com.tudou.home.commands.ad.*;
    import com.tudou.home.consts.*;
    import com.tudou.home.view.ad.base.*;
    import com.tudou.utils.*;
    import flash.display.*;
    import flash.events.*;

    public class AdCornerMediator extends AdBaseMediator implements IAdMediator
    {
        private var container:Sprite;
        public static var NAME:String = "cornerMediator";

        public function AdCornerMediator()
        {
            super(NAME, null);
            return;
        }// end function

        override public function clearAd() : void
        {
            while (container && container.numChildren > 0)
            {
                
                container.removeChildAt(0);
            }
            return;
        }// end function

        override public function getAdDisplay() : DisplayObject
        {
            return container;
        }// end function

        override public function setAdDisplay(param1:DisplayObject, param2:DisplayObject = null) : void
        {
            container = RectDisplayUtil.getMaskSprite(AdSize.CORNER_WIDTH, AdSize.CORNER_HEIGHT, 16711680, 0);
            container.visible = false;
            container.addChild(param1);
            param1.addEventListener(MouseEvent.CLICK, onClickCorner);
            return;
        }// end function

        private function onClickCorner(event:Event) : void
        {
            openURL(_adItemInfo.link);
            sendNotification(AdCornerCommandSet.AD_CLICK_CORNERAD);
            return;
        }// end function

        override public function showAd() : void
        {
            container.visible = true;
            sendNotification(AdCornerCommandSet.AD_SHOW);
            return;
        }// end function

    }
}
